home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / coding / 80x86 / code32.lzh / INDXBYTE.RT < prev    next >
Text File  |  1993-01-09  |  732b  |  30 lines

  1. public  _indexbyte
  2. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  3. ; Find a byte in a counted string and return index
  4. ; In:
  5. ;   AL - byte to find
  6. ;   EDX -> string of bytes, first byte is length
  7. ; Out:
  8. ;   CF=1 - not found
  9. ;   CF=0 - found
  10. ;     EAX - index
  11. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  12. _indexbyte:
  13.         push edi
  14.         push ecx
  15.         lea edi,[edx+1]
  16.         movzx ecx,byte ptr [edx]
  17.         repnz scasb
  18.         jnz short indexbytef0
  19.         movzx eax,byte ptr [edx]
  20.         sub eax,ecx
  21.         dec eax
  22.         jmp short indexbytef1
  23. indexbytef0:
  24.         stc
  25. indexbytef1:
  26.         pop ecx
  27.         pop edi
  28.         ret
  29.  
  30.